package org.rea.logic;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.rea.GUI.MainWindow;


public class FirstConnection {

	public static Connection collega(String username, String password){
		String url = "jdbc:oracle:thin:@linux3.dti.supsi.ch:1521:o102";
		Connection conn = null;

		try {
			conn = DriverManager.getConnection(url, username, password);
			conn.setAutoCommit(false);

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return conn;
	}


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		/*		// TODO Auto-generated method stub

		String nome = "koefer";
		String pass = "oraclei3a";



		PreparedStatement stmt;
		try {



			Connection connessione = collega(nome, pass);
			//stmt = connessione.createStatement();
			stmt = connessione.prepareStatement("select indirizzo from agenzie where nome = ?");
			//ResultSet rset = stmt.executeQuery("select indirizzo from agenzie");
			stmt.setString(1, "Fantaviaggi");
			ResultSet rset = stmt.executeQuery();
			while (rset.next()) {
				System.out.println (rset.getString(1));  
			}
			stmt.close();


		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}*/

		new MainWindow().setVisible(true);


	}
}
